﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace gvPoco.ChartOptions
{
    /// <summary>
    /// An object with members to configure various tooltip elements.
    /// </summary>
    public class ToolTip
    {
        /// <summary>
        /// If true, show colored squares next to the slice information in the tooltip.
        /// </summary>
        public bool showColorCode { get; set; }

        /// <summary>
        /// What information to display when the user hovers over a chart element. 
        /// The following values are supported: both, value, percentage
        /// </summary>
        public string text { get; private set; }

        /// <summary>
        /// An object that specifies the tooltip text style.
        /// </summary>
        public TextStyle textStyle { get; set; }

        /// <summary>
        /// The user interaction that causes the tooltip to be displayed:
        /// The following values are supported: hover, none
        /// </summary>
        public string trigger { get; private set; }

        public ToolTip()
        {
            showColorCode = false;
            text = "both";
            trigger = "hover";
            textStyle = new TextStyle();
        }

        /// <summary>
        /// Set what information to display when the user hovers over a chart element. 
        /// The following values are supported: both, value, percentage
        /// </summary>
        /// <param name="value">The value of the text property</param>
        public void SetText(string value)
        {
            string[] validText = { "both", "value", "percentage" };
            if (validText.Contains(value))
            {
                text = value;
            }
        }

        /// <summary>
        /// Set the user interaction that causes the tooltip to be displayed:
        /// The following values are supported: hover, none
        /// </summary>
        /// <param name="value">The value of the trigger property</param>
        public void SetTrigger(string value)
        {
            string[] validTriggers = { "hover", "none"};
            if (validTriggers.Contains(value))
            {
                trigger = value;
            }
        }
    }
}
